import request from '@/utils/request'

export function getMenusTree(pid) {
  return request({
    url: 'resource/lazy?pid=' + pid,
    method: 'get'
  })
}

export function getMenus(params) {
  return request({
    url: 'resource/all',
    method: 'get',
    params
  })
}

export function getTreeResource() {
  return request({
    url: 'resource/treeResource',
    method: 'get'
  })
}

export function getChild(id) {
  return request({
    url: 'resource/child?id=' + id,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'resource/add',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'resource/delete',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'resource/update',
    method: 'put',
    data
  })
}

export function generatePermission(tables) {
  return request({
    url: 'resource/generatePermission',
    method: 'post',
    data: tables
  })
}

export default { add, edit, del, getMenusTree, getTreeResource, getMenus, getChild, generatePermission }
